package com.wsc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

/**
 * restTemplate 请求接口
 */
@Controller
@RequestMapping("/restTemp")
public class RestTempController {

    /**
     * 通过 Http 协议访问远端接口
     * @return 远端接口返回的值
     */
    @RequestMapping("/getMsg")
    @ResponseBody
    public String getByHttp(){
        String url = "http://192.168.10.197:9527/cc/rest";
        RestTemplate restTemplate = new RestTemplate();
        return restTemplate.getForObject(url, String.class);
    }
}
